﻿using System;
using Autodesk.Revit.DB;
using YArchitech.Revit;

namespace YJKRevitStairs.StairsModel.CommonUnit
{
	public class BeamGeometryPosParamReader
	{
		public static BeamGeometryPosParamReader.YZAlignType IntToYZAT(int value)
		{
			BeamGeometryPosParamReader.YZAlignType result = BeamGeometryPosParamReader.YZAlignType.YZAT_Unify;
			if (value != 0)
			{
				if (value == 1)
				{
					result = BeamGeometryPosParamReader.YZAlignType.YZAT_Independent;
				}
			}
			else
			{
				result = BeamGeometryPosParamReader.YZAlignType.YZAT_Unify;
			}
			return result;
		}

		public static BeamGeometryPosParamReader.YAlignType IntToYAT(int value)
		{
			BeamGeometryPosParamReader.YAlignType result = BeamGeometryPosParamReader.YAlignType.YAT_Origin;
			switch (value)
			{
			case 0:
				result = BeamGeometryPosParamReader.YAlignType.YAT_Left;
				break;
			case 1:
				result = BeamGeometryPosParamReader.YAlignType.YAT_CenterLine;
				break;
			case 2:
				result = BeamGeometryPosParamReader.YAlignType.YAT_Origin;
				break;
			case 3:
				result = BeamGeometryPosParamReader.YAlignType.YAT_Right;
				break;
			}
			return result;
		}

		public static BeamGeometryPosParamReader.ZAlignType IntToZAT(int value)
		{
			BeamGeometryPosParamReader.ZAlignType result = BeamGeometryPosParamReader.ZAlignType.ZAT_Top;
			switch (value)
			{
			case 0:
				result = BeamGeometryPosParamReader.ZAlignType.ZAT_Top;
				break;
			case 1:
				result = BeamGeometryPosParamReader.ZAlignType.ZAT_CenterLine;
				break;
			case 2:
				result = BeamGeometryPosParamReader.ZAlignType.ZAT_Origin;
				break;
			case 3:
				result = BeamGeometryPosParamReader.ZAlignType.ZAT_Bottom;
				break;
			}
			return result;
		}

		public static int GetYZAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.YZ_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.YZAlignType GetYZAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToYZAT(BeamGeometryPosParamReader.GetYZAlignParamValue(beam));
		}

		public static int GetYAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.Y_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.YAlignType GetYAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToYAT(BeamGeometryPosParamReader.GetYAlignParamValue(beam));
		}

		public static int GetZAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.Z_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.ZAlignType GetZAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToZAT(BeamGeometryPosParamReader.GetZAlignParamValue(beam));
		}

		public static double GetYOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.Y_OFFSET_VALUE).AsDouble();
		}

		public static double GetZOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.Z_OFFSET_VALUE).AsDouble();
		}

		public static int GetStartYAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.START_Y_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.YAlignType GetStartYAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToYAT(BeamGeometryPosParamReader.GetStartYAlignParamValue(beam));
		}

		public static int GetStartZAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.START_Z_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.ZAlignType GetStartZAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToZAT(BeamGeometryPosParamReader.GetStartZAlignParamValue(beam));
		}

		public static double GetStartYOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.START_Y_OFFSET_VALUE).AsDouble();
		}

		public static double GetStartZOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.START_Z_OFFSET_VALUE).AsDouble();
		}

		public static int GetEndYAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.END_Y_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.YAlignType GetEndYAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToYAT(BeamGeometryPosParamReader.GetEndYAlignParamValue(beam));
		}

		public static int GetEndZAlignParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.END_Z_JUSTIFICATION).AsInteger();
		}

		public static BeamGeometryPosParamReader.ZAlignType GetEndZAlignType(FamilyInstance beam)
		{
			return BeamGeometryPosParamReader.IntToZAT(BeamGeometryPosParamReader.GetEndZAlignParamValue(beam));
		}

		public static double GetEndYOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.END_Y_OFFSET_VALUE).AsDouble();
		}

		public static double GetEndZOffsetParamValue(FamilyInstance beam)
		{
			return beam.GetParameter(BuiltInParameter.END_Z_OFFSET_VALUE).AsDouble();
		}

		public enum YZAlignType
		{
			YZAT_Unify,
			YZAT_Independent
		}

		public enum YAlignType
		{
			YAT_Left,
			YAT_CenterLine,
			YAT_Origin,
			YAT_Right
		}

		public enum ZAlignType
		{
			ZAT_Top,
			ZAT_CenterLine,
			ZAT_Origin,
			ZAT_Bottom
		}
	}
}
